export default defineBackground(() => {
  // 初始化 Service Worker
  browser.runtime.onInstalled.addListener(async (details) => {
    console.log('Service Worker installed:', details.reason)
    if (details.reason === 'install' || details.reason === 'update') {
      // 根据环境设置徽章文本
      if (isDev) {
        browser.action.setBadgeText({ text: 'dev' })
      }
      // 设置点击图标时打开侧边栏
      browser.sidePanel.setPanelBehavior({ openPanelOnActionClick: true })
      browser.commands.onCommand.addListener(async (command, tab) => {
        if (command === 'toggle_sidepanel') {
          browser.sidePanel.open({ windowId: tab.windowId })
        }
      })
    }
  })


})
